package com.dljd.demo;

import com.dljd.constant.MqConstant;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;
import org.junit.Test;

/**
 * @Author limin
 * @date 2025-06-15 23:02
 * @description
 */
public class COnewayTest {
    @Test
   public void onewayProducer() throws Exception{
        //创建一个生产者(指定一个组名)
        DefaultMQProducer producer = new DefaultMQProducer("oneway-produce-group");
        //连接namesrv
        producer.setNamesrvAddr(MqConstant.NAME_SRV_ADDR);
        //启动
        producer.start();
        //创建一个消息
        Message message = new Message("onewayTopic","日志info".getBytes());
        //发送消息
        producer.sendOneway(message);
        System.out.println("成功");
        //关闭生产者
        producer.shutdown();


    }
}
